#include <iostream>
#include <queue>
#include <vector>

using namespace std;

void test(){
    //priority_queue不支持{}初始化
    /* priority_queue<int> num = {1,2,3,4,5,6}; */

    vector<int> vec = {1,3,5,4,7,8,6,9,2,6,8};
    /* priority_queue<int> number = {vec.begin(),vec.end()}; */
    priority_queue<int> number;
    
    for(size_t index = 0;index != vec.size();++index)
    {
        number.push(vec[index]);
        cout << "堆顶是 " << number.top() << endl;
    }

    //priority_queue 里面没有迭代器，使用不能使用增强for循环来遍历
    //这个底层是依赖迭代器实现的
    /* for(auto &ele:number){ */
    /*     cout << ele << " "; */
    /* } */
    /* cout << endl; */

    while(!number.empty())//number.empty()为空则返回true
    {
        cout << number.top() << " ";//取出顶层(堆顶)，也就是最大值
        number.pop();//删除最大值
    }
    cout << endl;


}

int main()
{
    test();
    return 0;
}

